<!DOCTYPE html>
<html lang="en">
<head>
    <title>个人进拜访列表</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=4a6c1b54">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=16f1e6f3">
    <script src="https://file.ggxqce.com/web/vue.min.js"></script>
    <style>
        .lineOne {
            text-align: left;
        }

        .lineOne span {
            max-height: 35px;
            /*line-height: 20px;*/
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
            text-align: left;
        }

        .reginTd {
            max-width: 105px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            position: relative;
        }

        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }

        .row {
            margin-right: -15px;
            margin-left: 0px;
        }

        .col-lg-6, .col-xs-6, .col-md-6 {
            padding-left: 0;
        }

        .colorBS {
            background: #F9F9F9;
        }

        .table > tbody > tr > td {
            height: 35px;
        }
    </style>
</head>
<body>
<section class="content" id="app" v-cloak>
    <div class="div-td-content-more"><i></i></div>
    <h1 style="text-align: center;font-size: 20px;margin-bottom:10px;margin-top: 0;">
        {{name}}-{{type=="0"?"电访":"面访"}}-客户列表</h1>
    <div v-if="type==1">
        <div class="infoReport"><i></i>面访<span v-if="dateTime==yesterday">（昨日）</span>：目标（{{reportVisit.faceTargetInfo.dayTarget?reportVisit.faceTargetInfo.dayTarget:"0"}}），完成（{{reportVisit.faceTargetInfo.complete?reportVisit.faceTargetInfo.complete:"0"}}）
        </div>
        <table class="table text-center table-hover">
            <thead>
            <tr style="height:24px;">
                <th style="width:60px;" class="tableTitle">拜访日期</th>
                <th style="width:75px;" class="tableTitle">陪同人员</th>
                <th style="width:75px" class="tableTitle">客户姓名</th>
                <th style="width:85px" class="tableTitle">拜访时间</th>
                <th style="width:70px" class="tableTitle">拜访时长</th>
                <th class="tableTitle">面访签到</th>
                <th class="tableTitle">面访签退</th>
                <th style="width:80px;" class="tableTitle">时间间隔</th>
                <th style="width:90px;" class="tableTitle">距离间隔(公里)</th>
                <th class="tableTitle">拜访情况</th>
                <th style="width:95px" class="tableTitle">客户电话</th>
                <th style="width:95px" class="tableTitle">客户微信号</th>
                <!--<th >备注</th>-->
            </tr>
            </thead>
            <tbody>
            <tr v-for="(item,i) in reportVisit.faceTargetDay" :class="colorBS(item.date)?'colorBS':''">
                <td style="border-right:1px solid #cbcbcd;" :rowspan="item.datespan" :class="{hidden: item.datedis}">
                    {{(item.date).substr(5,10)?convertDate(item.date):"-"}}
                </td>
                <td>{{item.entourage}}</td>
                <td v-if="item.name">
                    {{item.name}}
                </td>
                <td v-else>-</td>
                <td>{{item.arrivalsTime}}-{{item.leaveTime}}</td>
                <td v-if="item.time!=0">{{item.time}}分</td>
                <td v-else>{{item.arrivalsTime?item.arrivalsTime:"-"}}/{{item.leaveTime?item.leaveTime:"-"}}
                <td class="lineOne" v-if="item.arrivalsImg" @click="openImg(item.arrivalsImg,0)" style="color:#169BD5;cursor: pointer">
                    <span>{{item.arrivalsAddress}}</span>
                </td>
                <td v-else class="lineOne"><span>{{item.arrivalsAddress}}</span></td>
                <td v-if="item.leaveImg" @click="openImg(item.leaveImg,1)" style="color:#169BD5;cursor: pointer" class="lineOne">
                    <span>{{item.leaveAddress}}</span>
                </td>
                <td v-else class="lineOne"><span>{{item.leaveAddress}}</span></td>
                </td>
                <td :style="timeJq(item.timeDiff)?'':'color:red'" v-if="item.arrivalsTime">
                    {{addZeroHour(quMiao(item.timeDiff))}}
                </td>
                <td v-else>-</td>
                <td :style="dJq(item.distance)?'':'color:red'" v-if="item.arrivalsTime">
                    <span v-if="item.timeDiff != ''">{{dJq(item.distance)}}</span>
                </td>
                <td v-else>-</td>

                <td class="lineOne"><span>{{item.otherCondition}}</span></td>

                <td>{{item.tel?item.tel.replace(/\s/g, ""):"-"}}</td>

                <td>{{item.wechat?item.wechat.replace(/\s/g, ""):"-"}}</td>


            </tr>
            </tbody>
        </table>
    </div>
    <div v-if="type==0">
        <div class="infoReport"><i></i>电访<span v-if="dateTime==yesterday">（昨日）</span>：目标（{{reportVisit.telTargeInfo.dayTarget?reportVisit.telTargeInfo.dayTarget:"-"}}），完成（{{reportVisit.telTargeInfo.complete?reportVisit.telTargeInfo.complete:"-"}}）
        </div>
        <table class="table table-bordered text-center table-hover">
            <thead>
            <tr style="height:35px;">
                <th style="width:160px" class="tableTitle">拜访日期</th>
                <th style="width:100px" class="tableTitle">客户电话</th>
                <th style="width:100px" class="tableTitle">客户姓名</th>
                <th style="width:100px" class="tableTitle">客户微信号</th>
                <th style="width:95px" class="tableTitle">拜访时间</th>
                <th style="width:70px" class="tableTitle">拜访时长</th>
            </tr>
            </thead>
            <tbody>
            <tr v-for="(item,i) in reportVisit.telTargetDay">
                <td :rowspan="item.datespan" :class="{hidden: item.datedis}">
                    {{item.date?item.date:"-"}}
                </td>
                <td>{{item.tel.replace(/\s/g, "")}}</td>
                <td>{{item.name?item.name:"-"}}</td>
                <td>{{item.wechat?item.wechat.replace(/\s/g, ""):"-"}}</td>
                <td>{{item.arrivalsTime}}-{{item.leaveTime}}</td>
                <td v-if="item.time!=0">{{item.time}}分</td>
                <td v-else=>-</td>
            </tr>
            </tbody>
        </table>
    </div>

    <!-- /.box-body -->
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=602456c3"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=6348cbbc"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script type="text/javascript" src="/dist/plugins/highcharts/highcharts.js"></script>
<script type="text/javascript">
    $(function () {
        $("body").on("click", ".lineOne", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + "px",
                        "left": $(this).offset().left,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });
</script>
<script type="text/javascript">
    var app = new Vue({
        el: '#app',
        data: {

            currentUser: getCurrentUser(),
            reportVisit: {
                "faceTargetInfo": {"dayTarget": "", "complete": ""},
                "telTargeInfo": {"dayTarget": "", "complete": ""}
            },
            userId: $.wyui.page.urlParams.userId,
            name: $.wyui.page.urlParams.name,
            dateTime: $.wyui.page.urlParams.dateTime,
            yesterday: new Date(new Date() - 24 * 60 * 60 * 1000).Format("yyyy-MM-dd"),
            today: new Date().Format("yyyy-MM-dd"),
            hour: new Date().getHours(),
            type: $.wyui.page.urlParams.type,
            colorDate: [],
        },
        methods: {
            isFair: function (item) {
                var str = '';
                if (!this.distanceJq(item.signInDistance) && !this.timeJq(item.signInTimeDiff)) {
                    str = "距离、时间不合理"
                }
                else if (!this.distanceJq(item.signInDistance)) {
                    str = "距离不合理"
                }
                else if (!this.timeJq(item.signInTimeDiff)) {
                    str = "时间不合理"
                }
                return str
            },
            //距离合理->true 不合理->false
            distanceJq: function (d) {
                var str = d.replace("公里", "");
                return Number(str) < 15
            },
            //时间合理->true 不合理->false
            timeJq: function (t) {
                /*if (t.indexOf("小时") > 0) {
                    var hour = t.split("小时")[0];
                    if (Number(hour) > 0) {
                        return false;
                    }
                } else {
                    if (t.indexOf("分") > 0) {
                        var min = t.split("分")[0];
                        if (Number(min) > 30) {
                            return false;
                        }
                    } else {
                        return true;
                    }
                }*/
                return true;
            },
            //时间间隔
            dJq: function (d) {
                var str = d.replace("公里", "");
                if (str == '0') {
                    return '';
                } else {
                    return Number(str).toFixed(2);
                }
            },
            //距离间隔
            disJq: function (dis) {
                var str = dis.replace("km/h", "");
                return str;
            },
            //去秒加0几分
            quMiao: function (m) {
                if (!m) return ""
                //1小时11分11秒
                var hour = "0"
                var min = "0"
                var sec = "0"

                if (m.indexOf("小时") > 0) {
                    //{1  , 11分11秒}
                    hour = m.split("小时")[0]
                }
                if (m.indexOf("分") > 0) {
                    //{1小时11，11秒}
                    min = m.split("分")[0]
                    if (min.indexOf("小时") > 0) {
                        //{1,11}
                        min = min.split("小时")[1]
                    }
                    if (Number(min) < 10) {
                        min = "0" + min
                    }
                }
                if (min == "0" && m.indexOf("秒") > 0) {
                    //21秒
                    return hour + "小时01分"
                }
                return hour + "小时" + min + "分"
            },
            //添加0小时xx分
            addZeroHour: function (h) {
                if (!h) {
                    return ""
                }
                if (h.indexOf('小时') > 0) {
                    return h
                } else {
                    return "0小时" + h
                }
            },
            //合并单元格
            tablesMergeCell: function (list) {
                if (list != undefined && list && list.length > 0) {
                    for (field in list[0]) {
                        var k = 0;
                        while (k < list.length) {
                            list[k][field + 'span'] = 1;
                            list[k][field + 'dis'] = false;
                            for (var i = k + 1; i <= list.length - 1; i++) {
                                if (list[k][field] == list[i][field] && list[k][field] != '') {
                                    list[k][field + 'span']++;
                                    list[k][field + 'dis'] = false;
                                    list[i][field + 'span'] = 1;
                                    list[i][field + 'dis'] = true;
                                } else {
                                    break;
                                }
                            }
                            k = i;
                        }
                    }
                }
                return list;
            },
            convertDate: function (str) {
                var oldTime = (new Date(str + " 20:11:11")).getTime();
                var curTime = new Date(oldTime).Format("M月d日");
                return curTime;
            },
            openImg: function (url, type) {
                var htl = "";
                var title = "";
                if (type == '0') {
                    title = '面访签到';
                } else {
                    title = '面访签退';
                }
                if (url) {
                    html = "<image class='imgStyle' src=" + url + " style='width:400px;height:500px;'>"
                } else {
                    html = "未上传照片！"
                }

                top.$.dialog({
                    content: html,
                    title: title,
                    width: 100,
                    height: 500,
                    max: false,
                    min: false,
                    lock: true
                });
            },
            lookInterview: function (item, i) {
                var that = this;
                url = "/page/reportForm/interview/interviewDetail.html";
                top.$.dialog({
                    content: 'url:' + url + '?id=' + item.id + "&index=" + i + "&userId=" + that.userId + "&dateTime=" + that.dateTime,
                    title: '拜访详情',
                    width: 300,
                    height: 500,
                    max: true,
                    min: true,
                    lock: true
                });
            },
            delEmpty: function (str) {
                if (str && str.indexOf("公里") < 0) {
                    return ""
                } else return str
            },
            colorBS: function (date) {
                var that = this;
                console.log($.inArray(date, that.colorDate) != -1);
                if ($.inArray(date, that.colorDate) != -1) {
                    return true;
                } else {
                    return false;
                }

            },
        },

        mounted: function () {
            var that = this;
            //获取前5个月 拼接出日期筛选框
            //查看参数
            if (!that.userId) {
                that.userId = getCurrentUser().userId;
            }
            $.wyui.postMethod(urlConfig.report.visitCustomer.getPeopleByUserId, {
                "userId": that.userId,
                "dateTime": that.dateTime,
                "today": that.today,
                "type": that.type
            }, function (map) {
                console.log(map)
                that.reportVisit = map;
                that.reportVisit.faceTargetDay = that.tablesMergeCell(that.reportVisit.faceTargetDay)
                that.reportVisit.telTargetDay = that.tablesMergeCell(that.reportVisit.telTargetDay)
                if (that.reportVisit.faceTargetDay != undefined && that.reportVisit.faceTargetDay && that.reportVisit.faceTargetDay.length > 0) {
                    that.colorBianSe = that.reportVisit.faceTargetDay[0].date;
                    var date = '';
                    var distance = '';
                    var timeDiff = '';
                    for (var i = 0; i < that.reportVisit.faceTargetDay.length; i++) {
                        if (date != that.reportVisit.faceTargetDay[i].date) {
                            that.colorDate.push(that.reportVisit.faceTargetDay[i].date);
                            that.reportVisit.faceTargetDay[i].distance = that.reportVisit.faceTargetDay[i].signInDistance;
                            that.reportVisit.faceTargetDay[i].timeDiff = that.reportVisit.faceTargetDay[i].signInTimeDiff;
                            if (date != '') {
                                that.reportVisit.faceTargetDay[i - 1].distance = distance;
                                that.reportVisit.faceTargetDay[i - 1].timeDiff = timeDiff;
                            }
                        } else {
                            that.reportVisit.faceTargetDay[i].distance = '';
                            that.reportVisit.faceTargetDay[i].timeDiff = '';
                            distance = that.reportVisit.faceTargetDay[i].signOutDistance;
                            timeDiff = that.reportVisit.faceTargetDay[i].signOutTimeDiff;
                        }
                        date = that.reportVisit.faceTargetDay[i].date;
                    }
                    if (that.colorDate && that.colorDate.length > 0) {
                        var colorTemp = that.colorDate;
                        that.colorDate = [];
                        for (var i = 0; i < colorTemp.length; i++) {
                            if (i % 2 != 0) {
                                that.colorDate.push(colorTemp[i]);
                            }
                        }
                        console.log(that.colorDate);
                    }
                }
            });
        }

    });
</script>
</body>
</html>